package com.wh.helloword;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;

/**
 * @Auther: HuiEr
 * @Date: 2020/2/25 21:23
 * @Description
 */
public class TestShiroHelloWorld {
    public static void main(String[] args) {
        IniSecurityManagerFactory iniSecurityManagerFactory = new IniSecurityManagerFactory("classpath:shiro.ini");
        SecurityManager securityManager = iniSecurityManagerFactory.getInstance();
        SecurityUtils.setSecurityManager(securityManager);
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken("huihuier", "111");
        subject.login(usernamePasswordToken);
        System.out.println("用户的认证状态是"+subject.isAuthenticated());
        subject.logout();
        System.out.println("用户的认证状态是"+subject.isAuthenticated());
    }
}
